﻿using Castle.DynamicProxy;

namespace RrslLite.Net.Aop
{
    public static class AopFactorySync
    {
        public static TTarget GetProxyInstance<TTarget>(string endpointConfigurationName) where TTarget : class 
        {
            var proxyGenerator = new ProxyGenerator();

            var wcfInterceptor = new InterceptorSync<TTarget>(endpointConfigurationName);

            TTarget proxyInstance = proxyGenerator.CreateInterfaceProxyWithoutTarget<TTarget>(wcfInterceptor);

            return proxyInstance;
        }
    }
}
